<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>

<title>edit</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">

<link rel="stylesheet"
	href="${pageContext.request.contextPath}/style/css/amazeui.min.css">
<link rel="stylesheet"
	href="${pageContext.request.contextPath}/style/css/app.css">
<link
	href="${pageContext.request.contextPath}/style/css/bootstrap.min.css"
	rel="stylesheet">
<link
	href="${pageContext.request.contextPath}/style/layui/css/layui.css"
	rel="stylesheet">
<script src="${pageContext.request.contextPath}/style/js/jquery.min.js"></script>
<script
	src="${pageContext.request.contextPath}/style/js/bootstrap.min.js"></script>
<script src="${pageContext.request.contextPath}/style/js/amazeui.min.js"></script>
<script type="text/javascript"
	src="${pageContext.request.contextPath}/style/layui/layui.js"></script>

</head>

<body>
		<form id="form" class="layui-form" action="#">
		<br>
		<div class="layui-form-item">

			<label class="layui-form-label">编号</label>
			<div class="layui-input-block" style="width:300px">
				<input type="text" class="am-form-field " name="pickId"
					readonly="true" id="pickId" value="${pick.pickId}">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">茶名</label>
			<div class="layui-input-block" style="width:300px">
				<input type="text" name="pickTeaname" value="${pick.pickTeaname}" required
					lay-verify="required" placeholder="请输入茶名" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">采摘方式</label>
			<div class="layui-input-block" style="width:300px">
				<select name="pickOperate" lay-verify="required">
					<c:forEach items="${codelist }" var="list">
						<option value="${list.codeValue }">${list.codeName }</option>
					</c:forEach>

				</select>
			</div>
			
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">茶园</label>
			<div class="layui-input-block" style="width:300px">
				<select name="pickLandid" lay-verify="required">
					<c:forEach items="${land }" var="l">
						<option value="${l.landId }">${l.landName }</option>
					</c:forEach>

				</select>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">重量</label>
			<div class="layui-inline" style="left:30px;width:250px">
				<input type="text" name="pickQuality" value="${pick.pickQuality}"  style="width:200px" required
					lay-verify="required|number" placeholder="请输入重量" autocomplete="off"
					class="layui-input">
			</div>
			<div class="layui-inline" style="left:-15px;width:5%">
				<label>克</label>

			</div>
		</div>
		 
	 
		<br>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button lay-submit class="btn btn-primary"
					lay-filter="go" id="sub">确定</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>

	</form>
</body>
<script type="text/javascript">
	layui.use('form', function() {
		var form = layui.form;

		form.on('submit(go)', function(data) {
			addproc();
			return false;
		});
		function addproc() {
			$.ajax({
				type : "POST",
				url : "${pageContext.request.contextPath}/pick/editproc",
				data : $("#form").serialize(),
				dataType : "text",
				success : function(res) {
					if (res == "success") {
						layui.use('layer',
								function() {
									var layer = layui.layer;
									var index = parent.layer
											.getFrameIndex(window.name);
									layer.alert('数据修改成功', {
										skin : 'layui-layer-molv' //样式类名
										,
										closeBtn : 0
									}, function() {
										parent.layer.close(index);
									});
								});
					}else if(res=="error"){
						layer.open({
							title : '数据修改',
							content : '仓库中鲜叶重量小于0，修改失败'
						});
					}else {
						alert("数据修改失败");
					}
				},
				error : function() {
					alert("error");
				}

			});
		}

	});
</script>
 
<script type="text/javascript">

$(document).ready(
		function() {
			 $("[name='pickOperate'] option[value='${pick.pickOperate}']").attr("selected","true");
			 $("[name='pickLandid'] option[value='${pick.pickLandid }']").attr("selected","true");

			//form.render();
		});

 
</script>
</html>
